﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NormalPlatform : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }


    private float shakeAmount = 0.16f;        // 阴影距离parent的半径  
    private Vector3 pos;

    private bool _isRock = false;

    public void StartRock()
    {
        pos = this.transform.position;
        _isRock = true;
    }

    public void DestroyPlatform()
    {
        _isRock = false;
        this.transform.position = pos;
        GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
        GetComponent<Collider2D>().enabled = false;
    }

    public bool GetRock()
    {
        return _isRock;
    }

    // Update is called once per frame
    void Update()
    {

        if (Time.frameCount % 5 == 0 && _isRock)
        {
            Debug.Log(transform.position);
            this.transform.position = pos + UnityEngine.Random.insideUnitSphere * shakeAmount;
        }
    }
}
